import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
  },
  getters: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
  }
})

let modulesFn = require.context('./modules', true, /\.js$/);
const reg = /.\/(.*?) \.js$/;
modulesFn.keys().forEach(filePath => {
  let moduleobj = modulesFn(filePath).default;
  moduleobj.namespaced = true;
  const regRes = reg.exec(filePath);
  const moduleName = regRes && regRes[1];
  moduleName && store.registerModule(moduleName, moduleobj)
})
export default store